#!/usr/bin/make -f

#export DH_VERBOSE=1

deb_source := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
deb_version := $(shell dpkg-parsechangelog | sed -n 's/^Version: //p')
upstream_version := $(shell echo '$(deb_version)' | sed 's/.*://; s/-[^-]*$$//')
git_rev := $(shell echo '$(upstream_version)' | sed 's/.*+//')

get-orig-source:
	rm -rf $(deb_source)-$(upstream_version)
	rm -f $(deb_source)-$(upstream_version).orig.tar.gz
	git clone https://github.com/robclark/libdri2.git $(deb_source)-$(upstream_version)
	cd $(deb_source)-$(upstream_version) && git archive \
		--format=tar \
		--prefix=$(deb_source)-$(upstream_version)/ \
		$(git_rev) \
		| gzip >../$(deb_source)_$(upstream_version).orig.tar.gz
	rm -rf $(deb_source)-$(upstream_version)

override_dh_auto_configure:
	dh_auto_configure -- --enable-test

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp

override_dh_install:
	find debian/tmp -name '*.la' -delete
	dh_install --fail-missing

%:
	dh $@ --with autoreconf --builddirectory=build/

